package com.sbuilder;

public class Demo04 {
    public static void main(String[] args) {
        int[] arr ={1,2,3};
        String str = arrayToString(arr);
        System.out.println(str);

    }
    public static String arrayToString(int[] arr){
        StringBuilder sbr = new StringBuilder();
        sbr.append("[");
        for(int i=0;i<arr.length;i++){
            if(i==arr.length-1){
                sbr.append(arr[i]).append("]");
            }else{
                sbr.append(arr[i]).append(",");
            }
        }
        String str = sbr.toString();
        return str;
    }
}
